/**
 * 
 */
package org.cuatrovientos.erp.business;

import java.util.List;

import org.apache.log4j.Logger;
import org.cuatrovientos.erp.dao.ProductTypeDAOInterface;
import org.cuatrovientos.erp.model.ProductType;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author natalia
 * This class implements ProductTypeBOInterface
 */
public class ProductTypeBO implements ProductTypeBOInterface{
	// Get log4j logger
		private static final Logger logger = Logger.getLogger(ProductTypeBO.class);
		
		@Autowired
	    private ProductTypeDAOInterface productTypeDAO;
		
	/**
	 * @param int id
	 * @return ProductType productType
	 * This method returns a productType selected by it's id
	 */
	@Override
	public ProductType selectById(int id) {
		logger.info("selectById: " + id);
		return productTypeDAO.selectById(id);
	}
	
	/**
	 * @return All the productTypes we have in the database
	 */
	@Override
	public List<ProductType> selectAll() {
		logger.info("selectAll: ");
		return productTypeDAO.selectAll();
	}
	
	/**
	 * @return The number of productTypes we have in the database
	 */
	@Override
	public List<ProductType> search(String name) {
		logger.info("search : " + name);
		return productTypeDAO.search(name);
	}
	
	/**
	 * @param int id
	 * This method deletes the productType selected by id
	 */
	@Override
	public void deleteById(int id) {
		logger.info("delete by: " + id + " id");
		productTypeDAO.deleteById(id);
	}
	
	/**
	 * @param ProductType productType
	 * This method insert a productType in the database passed by parameter
	 */
	@Override
	public void insert(ProductType productType) {
		logger.info("insert: " + productType);
		productTypeDAO.insert(productType);
	}
	
	/**
	 * @param ProductType productType
	 * This method updates a productType passed by parameter
	 */
	@Override
	public void update(ProductType productType) {
		logger.info("update: " + productType);
		productTypeDAO.update(productType);
	}
	
	/**
	 * @param ProductType productType
	 * This method deletes a productType passed by parameter
	 */
	@Override
	public void delete(ProductType productType) {
		logger.info("delete: " + productType);
		productTypeDAO.delete(productType);
	}

}
